package com.zang.server.controller;


import com.zang.server.annotation.OptLog;
import com.zang.server.pojo.Department;
import com.zang.server.pojo.RespBean;
import com.zang.server.service.IDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.zang.server.constanct.OptTypeConst.REMOVE;
import static com.zang.server.constanct.OptTypeConst.SAVE;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zang
 * @since 2021-12-28
 */
@RestController
@Api(tags = "部门管理")
@RequestMapping("/system/basic/department")
public class DepartmentController {

    @Autowired
    IDepartmentService iDepartmentService;


    @ApiOperation(value = "获取所有部门")
    @GetMapping("/")
    public List<Department> getAllDepartments(){
        return iDepartmentService.getAllDepartments();
    }
    @OptLog(optType = SAVE)
    @ApiOperation(value = "添加部门")
    @PostMapping("/")
    public RespBean addDep(@RequestBody Department dep){
     return    iDepartmentService.addDep(dep);
    }
    @OptLog(optType = REMOVE)
    @ApiOperation(value = "删除部门")
    @DeleteMapping("/{id}")
    public RespBean delete(@PathVariable("id") Integer id){
        return iDepartmentService.deleteDep(id);
    }
}
